<?php

class TravelRuleNameBehavior extends CActiveRecordBehavior{

	public function getRuleTitle() {
		$owner = $this->getOwner();
		$ruleName = '';
		if (!$owner->end_type) {
			$ruleName = '永久建团';
		} else {
			$ruleName = '从'.CUtilHelper::date()->changeFormat($owner->start_time,'Y-m-d').'开始'.CUtilHelper::date()->changeFormat($owner->end_time,'Y-m-d') ;
		}
		
		$ruleName .= '<br>';
		$ruleName .= '按'.$this->{$owner->build_type}($owner);
		return $ruleName.'发团';
	}
	
	public function ByWeek($model) {
		$name = '';
		$i = count($model->by_week)-1;
		foreach ($model->by_week as $key => $one) {
			$name .= Yii::app()->enum->lookUp('goods.travelBuildByWeek',$one);
			$name .= $i == $key ? '' :'、';
		}
		return $name;
	}
	public function ByDay($model) {
		return '每隔'.$model->by_day.'天';
	}
	public function ByDate($model) {
		$name = '';
		$i = count($model->by_date)-1;
		foreach ($model->by_date as $key => $one) {
			$name .= $one;
			$name .= $i == $key ? '' :'、';
		}
		return $name;
	}	
}

?>